package com.openbravo.pos.util;

import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;

public class AltEncrypter
{
  private Cipher cipherDecrypt;
  private Cipher cipherEncrypt;

  public AltEncrypter(String paramString)
  {
    try
    {
      SecureRandom localSecureRandom = SecureRandom.getInstance("SHA1PRNG");
      localSecureRandom.setSeed(paramString.getBytes("UTF8"));
      KeyGenerator localKeyGenerator = KeyGenerator.getInstance("DESEDE");
      localKeyGenerator.init(168, localSecureRandom);
      SecretKey localSecretKey = localKeyGenerator.generateKey();
      this.cipherEncrypt = Cipher.getInstance("DESEDE/ECB/PKCS5Padding");
      this.cipherEncrypt.init(1, localSecretKey);
      this.cipherDecrypt = Cipher.getInstance("DESEDE/ECB/PKCS5Padding");
      this.cipherDecrypt.init(2, localSecretKey);
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    catch (NoSuchPaddingException localNoSuchPaddingException)
    {
    }
    catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
    {
    }
    catch (InvalidKeyException localInvalidKeyException)
    {
    }
  }

  public String encrypt(String paramString)
  {
    try
    {
      return StringUtils.byte2hex(this.cipherEncrypt.doFinal(paramString.getBytes("UTF8")));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    catch (BadPaddingException localBadPaddingException)
    {
    }
    catch (IllegalBlockSizeException localIllegalBlockSizeException)
    {
    }
    return null;
  }

  public String decrypt(String paramString)
  {
    try
    {
      return new String(this.cipherDecrypt.doFinal(StringUtils.hex2byte(paramString)), "UTF8");
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
    }
    catch (BadPaddingException localBadPaddingException)
    {
    }
    catch (IllegalBlockSizeException localIllegalBlockSizeException)
    {
    }
    return null;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.util.AltEncrypter
 * JD-Core Version:    0.6.0
 */